package com.naire.modul.cusorg.action;

import java.util.ArrayList;
import java.util.List;

import net.common.action.GeneralAction;

import com.naire.modul.cusorg.service.CusorgDeleteService;
import com.naire.modul.cusorg.service.CusorgEditorService;
import com.naire.modul.cusorg.service.CusorgFindService;
import com.naire.modul.cusorg.service.CusorgJsonService;
import com.naire.modul.cusorg.vo.CusorgVo;
import com.naire.modul.customer.vo.FieldVo;

public class CusorgAction extends GeneralAction {

	private static final long serialVersionUID = 7127573666355745443L;

	private CusorgVo bean = new CusorgVo();
	private List<CusorgVo> list = new ArrayList<CusorgVo>();
	private List<FieldVo> fields = new ArrayList<FieldVo>();

	private String parent_code;
	private String dict_num;
	private String org_num;

	public void jsonCusorg() throws Exception {
		parent_code = org_num;
		CusorgJsonService service = new CusorgJsonService();
		service.setDict_num(dict_num);
		service.setParent_code(parent_code);
		service.invoke();
		json(service.getList());
	}

	public String search() throws Exception {
		CusorgJsonService service = new CusorgJsonService();
		service.setDict_num(dict_num);
		service.setParent_code(parent_code);
		service.setPageBean(pageBean);
		service.invoke();
		list = service.getList();
		return SUCCESS;
	}

	public String editor() throws Exception {
		CusorgEditorService service = new CusorgEditorService();
		service.setBean(bean);
		service.setDict_num(dict_num);
		service.setParent_code(parent_code);
		service.invoke();
		return SUCCESS;
	}

	public String find() throws Exception {
		Integer id = bean.getOrg_id();
		if (id != null) {
			CusorgFindService service = new CusorgFindService();
			service.setId(id);
			service.invoke();
			bean = service.getBean();
		}
		return SUCCESS;
	}

	public String delete() throws Exception {
		CusorgDeleteService service = new CusorgDeleteService();
		service.setBean(bean);
		service.invoke();
		return SUCCESS;
	}

	public CusorgVo getBean() {
		return bean;
	}

	public void setBean(CusorgVo bean) {
		this.bean = bean;
	}

	public List<CusorgVo> getList() {
		return list;
	}

	public void setList(List<CusorgVo> list) {
		this.list = list;
	}

	public List<FieldVo> getFields() {
		return fields;
	}

	public String getParent_code() {
		return parent_code;
	}

	public void setParent_code(String parent_code) {
		this.parent_code = parent_code;
	}

	public String getDict_num() {
		return dict_num;
	}

	public void setDict_num(String dict_num) {
		this.dict_num = dict_num;
	}

	public String getOrg_num() {
		return org_num;
	}

	public void setOrg_num(String org_num) {
		this.org_num = org_num;
	}
}
